﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;

public partial class delete_select_course : System.Web.UI.Page
{
    string Sno;
    string Cno;
    string Sname;
    string Cname;

    protected void Page_Load(object sender, EventArgs e)
    {
        Sname = Request.QueryString["Sname"];
        Cname = Request.QueryString["Cname"];
        Response.Write(" 请确认删除学生'"+Sname+"'的课程'"+Cname+"' ");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Sno = Request.QueryString["Sno"];
        Cno = Request.QueryString["Cno"];
        string conn = "Data Source= . ;Initial Catalog=XSXK; User ID=sa; pwd=123";
        SqlConnection connection = new SqlConnection(conn);
        try
        {
            connection.Open();
            SqlCommand comm = new SqlCommand();
            comm.Connection = connection;

            string str_sql = " delete from Select_course where Sno='"+Sno+"' and Cno='"+Cno+"' ";
            comm.CommandText = str_sql;
            comm.ExecuteNonQuery();

        }
        catch (SqlException ex)
        {
            Response.Write(ex.Message);
        }

        finally
        {
            connection.Close();//关闭数据库连接
        }
    }
}